  
<h1>Listing messages</h1>

<table>
  <thead>
    <tr>
      <th>Real name</th>
      <th>Create time</th>
      <th>Msg type</th>
      <th>Content</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <% @messages.each do |message| %>
      <tr>
        <td>
          <% p guest = GuestName.find_by_from_user_name(message.from_user_name) %>
          <% if guest != nil %>
            <%= guest.real_name %>
          <% else %>
          来宾
          <% end %>          
        </td>
        <td><%= message.create_time %></td>
        <td><%= message.msg_type %></td>
        <td><%= message.content %></td>
        <td><%= link_to 'Show', message %></td>
        <td><%= link_to 'Edit', edit_message_path(message) %></td>
        <td><%= link_to 'Destroy', message, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Message', new_message_path %>